package com.ftg.learn.rbac.controller;


import com.ftg.learn.rbac.entity.Role;
import com.ftg.learn.rbac.service.IRoleService;
import com.ftg.learn.util.BaseController;
import com.ftg.learn.util.ResEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Guobt
 * @since 2022-02-09
 */
@RestController
@RequestMapping("/rbac/role")
@Api(tags="角色管理功能列表")
public class RoleController extends BaseController<Role, IRoleService> {

    @GetMapping("/showPermissionForRoleId")
    @ApiOperation(value = "查某角色具有的权限")
    public ResEntity showRoleForUserId(@RequestParam Long rid){
        return new ResEntity(0,"success",super.service.showPermissionForRoleId(rid));
    }


    @PostMapping("/permissionGroup")
    @ApiOperation(value = "对操作的角色删除当前权限及添加新权限")
    public ResEntity roleGroup(@RequestParam Long rid, @RequestParam List<Long> pid){
        return new ResEntity(0,"success",super.service.permissionGroup(rid,pid));
    }

}
